package com.xmy.aboutexception;

import java.io.*;
import java.util.Scanner;

public class Demo3 {
    public static void main(String[] args) {
        Scanner scanner = null;

        try {
            scanner = new Scanner(new File("F://git//testgit//readme.txt"));
            while (scanner.hasNext()) {
                System.out.println(scanner.nextLine());
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            if (scanner != null) {
                scanner.close();
            }
        }

        try (Scanner in = new Scanner(new File("F://git//testgit//readme.txt"))) {
            while (in.hasNext()) {
                System.out.println(in.nextLine());
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        try (BufferedInputStream bin = new BufferedInputStream(new FileInputStream(new File("F://git//testgit//readme.txt")));
             BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(new File("F://git//testgit//out.txt")))) {
            int b;
            while ((b = bin.read()) != -1) {
                bout.write(b);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
